app.directive('appAuth', ['$animate', '$state', 'UserInfo', function ($animate, $state, UserInfo) {
    return {
        restrict: 'AC',
        priority: 1000,
        link: function ($scope, $element, $attr, ctrl, $transclude) {
            var Auth_HIDE_CLASS = 'ng-hide';
            var NG_HIDE_IN_PROGRESS_CLASS = 'ng-hide-animate';

            var uiSref = $attr.uiSref || $attr.appAuth;
            var targetState = $state.get(uiSref);

            $scope.$watch('authorities', function ngIfWatchAction(value) {
                var hasAuth = UserInfo.isAuthorizedForState(targetState);
                $animate[hasAuth ? 'removeClass' : 'addClass']($element, Auth_HIDE_CLASS, {
                    tempClasses: NG_HIDE_IN_PROGRESS_CLASS
                });

            });
            //if (targetState && targetState.data && targetState.data.authorities && targetState.data.authorities.length > 0) {
            //    var authorities = targetState.data.authorities;
            //
            //
            //
            //
            //}
        }
    };
}]);